package com.wkhyapp.lm.contract;

import android.util.Log;

import com.wkhyapp.lm.base.BasePresenter;
import com.wkhyapp.lm.http.ApiCallback;
import com.wkhyapp.lm.http.net.BaseRequest;
import com.wkhyapp.lm.http.net.GoodsListRequest;
import com.wkhyapp.lm.http.net.SuperResponse;
import com.wkhyapp.lm.http.vo.Goods;
import com.wkhyapp.lm.http.vo.Member;
import com.wkhyapp.lm.utils.PreferenceUtils;

/**
 * Created by Administrator on 2021-10-1.
 */

public class MyPresenter extends BasePresenter<MyView> {


    boolean flag = true;

    public MyPresenter(MyView myView) {
        super(myView);
    }



    public void getData(int userId){
        BaseRequest request = new BaseRequest();
        request.setUserId(userId);
        addSubscription(apiStores.memberInfo(request),new ApiCallback<SuperResponse<Member>>() {
            @Override
            public void onSuccess(SuperResponse<Member> response) {
                mvpView.setMember(response.getItem());
            }
            @Override
            public void onFailure(String msg) {
//                mvpView.setfail("");
            }

            @Override
            public void onFinish() {
                mvpView.dismissLoad();
            }
        });

    }


    public void init(){
        BaseRequest request = new BaseRequest();
        addSubscription(apiStores.getclickid(request),new ApiCallback<SuperResponse<String>>() {
            @Override
            public void onSuccess(SuperResponse<String> str) {
                Log.e("getclickid:","请求成功");
                mvpView.setMember(null);
            }
            @Override
            public void onFailure(String msg) {
            }

            @Override
            public void onFinish() {
                Log.e("getclickid:","请求结束2");
                PreferenceUtils.getInstance().setPrefBoolean("init",true);
            }
        });

    }


}
